<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <!-- 主表单区域 -->
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="8" >
            <a-form-model-item label="时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="date">
              <a-input v-model="model.date" placeholder="请输入时间" ></a-input>
            </a-form-model-item>
          </a-col>

        </a-row>
        <a-row>
          <a-col :span="8" >
            <a-form-model-item label="获奖类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="level">
              <j-dict-select-tag type="list" v-model="model.level" dictCode="FDYSZNLDS_LEVEL" placeholder="请选择获奖类型" @change="getTotalScore"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="获奖级别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="classess">
              <j-dict-select-tag type="list" v-model="model.classess" dictCode="FDYSZNLDS_CLASSESS" placeholder="请选择获奖级别" @change="getTotalScore"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="总分" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }" prop="totalScore">
              <a-input v-model="model.totalScore" placeholder="" :disabled="true"></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="8">
            <a-form-model-item label="教师" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teacherId">
              <j-select-user-by-dep  v-model="model.teacherId" @change="(...args)=>{selectedUser(...args)}" :multi="false"></j-select-user-by-dep>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="教工编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input placeholder="教工编号" v-model="model.teacherId" :disabled="true"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="积分学院" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orgId_dictText">
              <teaching-depart v-model="model.orgId"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-col :span="24" >
          <a-form-model-item label="备注" :labelCol="{ span: 2 }" :wrapperCol="{ span: 22 }" prop="remark">
            <a-input  v-model="model.remark" placeholder="请输入备注" :rows="3" />
          </a-form-model-item>
        </a-col>
      </a-form-model>
    </j-form-container>
      <!-- 子表单区域 -->
  </a-spin>
</template>

<script>

import { getAction } from '@/api/manage'
import GYearPicker from '@views/gfxy/common/GYearPicker'
import {GfxyOneToOneMixin} from '@/mixins/GfxyOneToOneMixin'
import JSelectDepart from '@comp/jeecgbiz/JSelectDepart.vue'
import TeachingDepart from '@comp/gfxy/TeachingDepart.vue'
  export default {
    name: 'FdysznldsForm',
    mixins: [GfxyOneToOneMixin],
    components: {
      TeachingDepart,
      GYearPicker,JSelectDepart
    },
    data() {
      return {
        confirmLoading : false,
        // 新增时子表默认添加几行空数据

        validatorRules: {
          date: [
            { required: true, message: '请输入时间!'},
          ],
          level:[
            { required: true, message: '请选择获奖类型!'},
          ],
          classess: [
            { required: true, message: '请选择获奖级别!'},
          ],
          teacherId: [
            { required: true, message: '请选择教师!'},
          ],

        },

        url: {
          add: "/items/fdysznlds/add",
          edit: "/items/fdysznlds/edit",
          queryById: "/items/fdysznlds/queryById",
          getTotalScore: "/items/fdysznlds/getTotalScore",
          memberList: {
            list: '/items/fdysznlds/queryMemberListByMainId'
          },

        }
      }
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      },
      itemValue:{
        type: Number,
        required: true,
      },
      date:{
        type: String,
        required: true,
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
    },
    methods: {

      getTotalScore() {

        if (this.model.classess != undefined && this.model.level  != undefined) {
          this.confirmLoading = true;
          getAction(this.url.getTotalScore, { classess: this.model.classess, level: this.model.level }).then((res) => {
            if (res.success) {
              this.model.totalScore = res.result;
              // this.$nextTick(()=>{
              //   this.$refs.memberListRef.getScore();
              // })
            }
            if(res.code===510){
              this.$message.warning(res.message)
            }
            this.confirmLoading = false;
          })
        }
      },

    }
  }
</script>

<style scoped>
</style>